﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TracyGUI.UIComponent
{
    class TabPageEntry : TabPage
    {
        public const string TABPAGE_NAME_RESOURCES = "Resources";
        public const string TABPAGE_NAME_FILES = "Files";
        public const string TABPAGE_NAME_ALL = "All";
        public const string TABPAGE_NAME_SEARCH = "Search";
        public const string TABPAGE_NAME_UE = "Ultra Explorer";
        private SplitContainer _splitContainer;
        private FlowLayoutPanel _tagPanel;
        public FlowLayoutPanel TagPanel
        {
            get
            {
                if (_tagPanel == null)
                {
                    //Init Tag Panel
                    GroupBox gp = new GroupBox();
                    gp.Text = "Tags";
                    gp.Dock = DockStyle.Fill;
                    _tagPanel = new FlowLayoutPanel();
                    _tagPanel.Dock = DockStyle.Fill;
                    gp.Controls.Add(_tagPanel);
                    _splitContainer.Panel2.Controls.Add(gp);
                }
                return _tagPanel;
            }
        }

        private TabControl _tabControl;
        
        public TabControl TabControl
        {
            get { return _tabControl; }
        }

        public TabPageEntry(string name, string text)
        {
            this.Name = name;
            this.Text = text;
            Init();
        }

        public bool TagPanelCollapsed
        {
            get { return _splitContainer.Panel2Collapsed; }
            set { _splitContainer.Panel2Collapsed = value; }
        }

        

        private void Init()
        {
            //Init Split Container
            _splitContainer = new SplitContainer();
            _splitContainer.Orientation = Orientation.Vertical;
            _splitContainer.FixedPanel = FixedPanel.Panel2;
            _splitContainer.Dock = DockStyle.Fill;
            _splitContainer.Panel2MinSize = 130;
            this.Controls.Add(_splitContainer);
            TagPanelCollapsed = true;

            //Init Tab Control
            _tabControl = new TabControl();
            TabControl.Dock = DockStyle.Fill;
            TabControl.Alignment = TabAlignment.Left;
            _splitContainer.Panel1.Controls.Add(_tabControl);
        }

        public TabPage GetTabPage(string pageName)
        {
            if (TabControl.TabPages.ContainsKey(pageName))
            {
                return TabControl.TabPages[pageName];
            }
            return null;
        }
    }
}
